//
//  TestViewController.m
//  NXScrollPageView
//
//  Created by N-X on 2018/3/26.
//  Copyright © 2018年 MRNAN. All rights reserved.
//

#import "TestViewController.h"

static CGFloat const itemSpace = 10;
static CGFloat const leftSpace = 10;

@interface TestViewController ()<UICollectionViewDelegate,UICollectionViewDataSource>
@property (nonatomic ,strong)UICollectionView * collectionView;
@property (nonatomic ,strong)NSArray * dataArray;
@end

@implementation TestViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor blueColor];
    [self.view addSubview:self.collectionView];
    
//    LittleMasterNoteBaseModel * model = [[LittleMasterNoteBaseModel alloc]init];
//    [model requestLittleMasterChoosenessData:^(id result) {
//        self.dataArray = result;
//        [self.collectionView reloadData];
//    }];
    
    self.dataArray = @[@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1",@"1"];
    [self.collectionView reloadData];
}


- (UICollectionView *)collectionView
{
    if (!_collectionView) {
        UICollectionViewFlowLayout * layout = [[UICollectionViewFlowLayout alloc]init];
        _collectionView = [[UICollectionView alloc]initWithFrame:self.view.bounds collectionViewLayout:layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        CGFloat itemW = ([UIScreen mainScreen].bounds.size.width  - itemSpace - leftSpace * 2) / 2 ;
        CGFloat itemH = 248 * itemW / 182;
        layout.itemSize = CGSizeMake(itemW, itemH);
        layout.minimumInteritemSpacing = itemSpace;
        layout.minimumLineSpacing = itemSpace;
        _collectionView.backgroundColor = [UIColor colorWithRed:236/255.0 green:237/255.0 blue:237/255.0 alpha:1];//NX_ColorFromRGB(236, 237, 237);
//        [_collectionView registerClass:[FHHomeSeckillItemCollectionCell class] forCellWithReuseIdentifier:fhhomeSeckillItemCollectionCellID];
        [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellID"];

    }
    return _collectionView;
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _dataArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellID" forIndexPath:indexPath];
//    FHHomeItemBaseModel * model = self.dataArray[indexPath.item];
//    cell.homeItemBaseModel = model;
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}


@end
